<?php

Yii::app()->clientScript->registerScriptFile('http://maps.google.com/maps/api/js?sensor=false');
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/scripts/gmap3.min.js');
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/scripts/typing.min.js');
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl.'/scripts/msdropdown.js');
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/css/msdropdown.css');

$form=$this->beginWidget('ext.bootstrap.widgets.BootActiveForm',array(
	'id'=>'program-form',
	'enableAjaxValidation'=>true,
    'enableClientValidation'=>true,
    'htmlOptions' => array('enctype'=>'multipart/form-data'),
)); ?>
<div class="row">

<div class="span6">
	<p class="help-block">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<?php echo $form->textFieldRow($model,'nev',array('class'=>'span5','maxlength'=>100)); ?>
    
    <div>
    <label>Icon:</label>
    
    <select style="height: 40px;" class="span4" name="Program[icon]" id="Program_icon">
    <?php
      $path = Yii::app()->baseUrl.'/images/mapicons/';
      foreach($icons as $icon){
        $p = $path.$icon;
        $name = explode('.',$icon);
        $name = $name[0];
        echo "<option value='$icon' title='$p' ". ($icon == $model->icon ? "selected='selected'":'') ." >$name</option>";
      }  
        
    ?>    
    </select>
    
    </div>
    <br />
	<?php echo $form->textAreaRow($model,'leiras',array('rows'=>6, 'cols'=>10, 'class'=>'span5')); ?>


    <p>
    Dátum:*<br />
	<?php Yii::import('ext.CJuiDateTimePicker.CJuiDateTimePicker');
        $this->widget('CJuiDateTimePicker',array(
            'model'=>$model, //Model object
            'attribute'=>'datum', //attribute name
            'mode'=>'datetime', //use "time","date" or "datetime" (default)
            'options'=>array(), // jquery plugin options
            'language'=>'hu',
        ));
    ?>
    </p>
    
    <?php echo $form->textFieldRow($model,'address',array('class'=>'span5','maxlength'=>100)); ?>
    
    <?php echo $form->fileFieldRow($model, 'image', array('class'=>'span5')); ?>
    
	<div class="actions">
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save',array('class'=>'btn primary')); ?>
	</div>
 </div>
 
 <div class="span6">
    <div style="height: 400px;margin: 10px 0; overflow: auto;padding: 10px 0;position: relative;border: 1px dashed gray;" id="googleMap"></div>
 </div>
</div>
<?php $this->endWidget(); 

Yii::app()->clientScript->registerScript('map', <<<EEGMAP

$(function(){
    
    $('#Program_icon').msDropDown();
   
   $('#Program_address').typing({
   
   stop: function(event, elem){
    _address = $(elem).val();
    $('#googleMap').gmap3(
        {action:'clear', name:'marker'},    
        { action: 'addMarker',
            address: _address,
            map:{
              center: true,
              zoom: 14
            },
            marker:{
              options:{
                draggable: false
              }
            },        
        }
	); 
            
    },
   delay:1500
   });// end type 
    
    var __add = $('#Program_address').val() == '' ? 'Szeged, Magyarország' :  $('#Program_address').val();
    $('#googleMap').gmap3(
      { action: 'addMarker',
        address: __add,
        map:{
          center: true,
          zoom: 14
        },
        marker:{
          options:{
            draggable: true
          }
        },
      }
    ); 
});


EEGMAP
, CClientScript::POS_READY);

?>
